package fitness;

import org.jgap.FitnessFunction;
import org.jgap.IChromosome;

import character.Warlock;

public class WarlockFitness extends FitnessFunction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8821837276908749843L;

	@Override
	protected double evaluate(IChromosome profile) {

		Integer strength = (Integer) profile.getGene(0).getAllele();
		Integer agility =  (Integer) profile.getGene(1).getAllele();
		Integer stamina =  (Integer) profile.getGene(2).getAllele();
		Integer intellect =  (Integer) profile.getGene(3).getAllele();
		Integer spirit =  (Integer) profile.getGene(4).getAllele();
		
		Warlock warlock = new Warlock();
		warlock.setStrength(strength);
		warlock.setAgility(agility);
		warlock.setStamina(stamina);
		warlock.setIntellect(intellect);
		warlock.setSpirit(spirit);
		
		double res = 1.031 * warlock.getAttackPower() +
					 2.062  * warlock.getArmor() + 
					 4.124  * warlock.getSpeed() +
					 2.062  * warlock.getResilience() + 
					 2.062  * warlock.getDodgeRating() + 
					 3.093 * warlock.getMana() +
					 1.031 * warlock.getHealth() +
					 32.989  * warlock.getSpellPenetration() +
					 20.619  * warlock.getHaste() + 
					 8.247  * warlock.getHealthRegeneration() +
					 22.680  * warlock.getManaRegeneration();
		return res;
	}

}
